<?php if (!isset($_SESSION)) session_start(); ?>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="../../docs-assets/ico/favicon.png">

<title>Koreanet</title>

<!-- Nanum Webfont -->
<style>
* {
	font-family: 'NanumGothic' !important;
}
</style>
<script src="http://www.google.com/jsapi"></script>
<script>
 google.load( "webfont", "1" );
 google.setOnLoadCallback(function() {
  WebFont.load({ custom: {
   families: [ "NanumGothic" ],
   urls: [ "http://fontface.kr/NanumGothic/css" ]
  }});
 });
</script>

<!-- Bootstrap core CSS -->
<link href="./dist/css/bootstrap.css" rel="stylesheet">

<!-- Custom styles for this template -->
<link href="./css/monthly_report.css" rel="stylesheet">

</head>

<body>
<?php include 'header.php';?>
<?php require_once './class/MonthlyReport.inc';?>
<?php require_once './class/Attendance.inc';?>
<?php

if ($login == null || $login->getGrade () > 2) {
	echo "<script type='text/javascript'>";
	echo "location.replace('./main.php');";
	echo "</script>";
	exit ();
}
?>
	<div class="container container_bottom">
		<div class="row">
			<div class="col-md-12">
				<h2>월 결산</h2>
			</div>
		</div>
		<div class="table-responsive col-md-12 row_margin"
			style="overflow: scroll;">
			<table class="table table-bordered" id="attendance_table">
			 		<?php
						$getId = $_GET ['id'];
						$getTime = $_GET ['time'];
						echo "<form class='form-signin' role='form' method='post' action='./ajax/modify_monthly_report_data.php'>";
						
						$monthlyReport = new MonthlyReport ();
						$monthlyReport->search4Detail ( $getId, $getTime );
						
						$atten = new Attendance ();
						$atten->searchAttendance ( $getId, $getTime );
						?>
				</table>
		</div>
		<div class="table-responsive">
			<table class="table table-bordered">
				<!-- tableSorter의 editable table plugin을 쓸 것. -->
				<thead>
					<tr class="tr_head">
						<th colspan="11">결산정보</th>
					</tr>
					<tr>
						<th>사원번호</th>
						<th>성명</th>
						<th>차량번호</th>
						<th colspan="2">차량번호등록판</th>
						<th colspan="2">거래처</th>
						<th colspan="2">근무점포</th>
						<th colspan="2">기사구분</th>
						<!-- 						<th>지급은행</th> -->
						<!-- 						<th>예금주명</th> -->
						<!-- 						<th colspan="2">계좌번호</th> -->
						<!-- 						<th>결산일</th> -->
						<!-- 						<th>지급액</th> -->
					</tr>
				</thead>
				<tbody>
					<tr>
						<td><input id='mem_id' name="mem_id" type='text'
							class='form-control' value='<?php echo $monthlyReport->mem_id ?>'
							readonly="readonly"></td>
						<td><input type='text' class='form-control'
							value='<?php echo $monthlyReport->name ?>' readonly="readonly"></td>
						<td><input type='text' class='form-control'
							value='<?php echo $monthlyReport->car_id ?>' readonly="readonly"></td>
						<td colspan="2"><input type='text' class='form-control'
							value='<?php echo $monthlyReport->car_no ?>' readonly="readonly"></td>
						<td colspan="2"><input type='text' class='form-control'
							value='<?php echo $monthlyReport->cusm_cd ?>' readonly="readonly"></td>
						<td colspan="2"><input type='text' class='form-control'
							value='<?php echo $monthlyReport->c_brno ?>' readonly="readonly"></td>
						<td colspan="2"><input type='text' id='soyu_tp' name='soyu_tp' class='form-control'
							value='<?php echo $monthlyReport->soyu_tp ?>' readonly="readonly"></td>
					</tr>
				</tbody>
				<thead>
					<tr>
						<th colspan="2">결산일</th>
						<th colspan="2">지급은행</th>
						<th>예금주명</th>
						<th colspan="2">계좌번호</th>
						<th colspan="2">지급일</th>
						<th colspan="2">지급액</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td colspan="2"><input type='text' id="sply_dt" name="sply_dt" class='form-control' 
							value='<?php echo $monthlyReport->sply_dt ?>'
							readonly="readonly"></td>
						<td colspan="2"><input type='text' class='form-control'
							value='<?php echo $monthlyReport->bank_nm ?>' readonly="readonly"></td>
						<td><input type='text' class='form-control'
							value='<?php echo $monthlyReport->act_nm ?>' readonly="readonly"></td>
						<td colspan="2"><input type='text' class='form-control'
							value='<?php echo $monthlyReport->actno ?>' readonly="readonly"></td>
						<td colspan="2"><input type='text' class='form-control'
							value='<?php echo $monthlyReport->closing_date ?>' readonly="readonly"></td>
						<td colspan="2"><input id='total_sply_amt' name='total_sply_amt'
							type='text' class='form-control' maxlength='20'
							value='<?php echo number_format($monthlyReport->sply_amt); ?>'
							readonly="readonly"></td>
					</tr>
				</tbody>
				<!-- 			</table> -->
				<!-- 			<table class="table table-bordered"> -->
				<thead>
					<tr class="tr_head">
						<th colspan="11">운송료</th>
					</tr>
					<tr>
					<?php
					// 거래처에 따라 출력 내용 변동. ture = 이커머스, false = 익스프레스, else = 직영 4대보험
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
							echo "<th>기본 운송료</th><th>통신비</th><th>세차비</th><th>만근지원비</th><th>운행장려금</th><th>용차비</th><th>운송료추가</th><th>기타</th><th>기타2</th><th>Early Slot</th><th>건당인센티브</th>";
							break;
						case 2 : // 익스프레스
							echo "<th>기본 운송료</th><th>유류비</th><th>휴무공제</th><th>인센티브</th><th>운송료 추가</th><th>기타(지급)</th><th>기타(공제)</th><th></th><th></th><th colspan='2'></th>";
							break;
						case 3 : // 직영4대보험
							echo "<th>기본급여</th><th>연장수당</th><th>연차수당</th><th>EARLY SLOT</th><th>디스패쳐</th><th>교통비</th><th>식대비</th><th>차량보조</th><th>기타수당</th><th>기타경비</th><th></th>";
							break;
					}
					?>
					</tr>
				</thead>
				<tbody>
					<tr>
						<?php
						echo "<td><input id='fare_amt' name='fare_amt' type='text' class='form-control'";
						echo " maxlength='20'";
						echo " onkeyup='javascript:sumFareVal(this)'";
						echo " value='" . number_format ( $monthlyReport->fare_amt ) . "'></td>";
						?>
						<?php
						switch ($monthlyReport->gubun_tp) {
							case 1 : // 이커머스
								echo "<td><input id='comm_exp' name='comm_exp' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->comm_exp ) . "'></td>";
								break;
							case 2 : // 익스프레스
								echo "<td><input id='oil_exp' name='oil_exp' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->oil_exp ) . "'></td>";
								break;
							case 3 : // 직영4대보험
								echo "<td><input id='extension_pay' name='extension_pay' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->extension_pay ) . "'></td>";
								break;
						}
						?>
						<?php
						switch ($monthlyReport->gubun_tp) {
							case 1 : // 이커머스
								echo "<td><input id='car_wash_exp' name='car_wash_exp' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->car_wash_exp ) . "'></td>";
								break;
							case 2 : // 익스프레스
								echo "<td><input id='dayoff_dedt' name='dayoff_dedt' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->dayoff_dedt ) . "'></td>";
								break;
							case 3 : // 직영4대보험
								echo "<td><input id='annual_pay' name='annual_pay' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->annual_pay ) . "'></td>";
								break;
						}
						?>
						<?php
						switch ($monthlyReport->gubun_tp) {
							case 1 : // 이커머스
								echo "<td><input id='attend_exp' name='attend_exp' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->attend_exp ) . "'></td>";
								break;
							case 2 : // 익스프레스
								echo "<td><input id='ex_incen_pay' name='ex_incen_pay' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->ex_incen_pay ) . "'></td>";
								break;
							case 3 : // 직영4대보험
								echo "<td><input id='early_slot' name='early_slot' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->early_slot ) . "'></td>";
								break;
						}
						?>							
						<?php
						switch ($monthlyReport->gubun_tp) {
							case 1 : // 이커머스
								echo "<td><input id='incen_pay' name='incen_pay' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->incen_pay ) . "'></td>";
								break;
							case 2 : // 익스프레스
								echo "<td><input id='apd_dil_exp' name='apd_dil_exp' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->apd_dil_exp ) . "'></td>";
								break;
							case 3 : // 직영4대보험
								echo "<td><input id='dispatcher_amt' name='dispatcher_amt' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->dispatcher_amt ) . "'></td>";
								break;
						}
						?>
						<?php
						switch ($monthlyReport->gubun_tp) {
							case 1 : // 이커머스
								echo "<td><input id='dil_van_exp' name='dil_van_exp' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->dil_van_exp ) . "'></td>";
								break;
							case 2 : // 익스프레스
								echo "<td><input id='dil_etc_exp' name='dil_etc_exp' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->dil_etc_exp ) . "'></td>";
								break;
							case 3 : // 직영4대보험
								echo "<td><input id='commit_pay' name='commit_pay' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->commit_pay ) . "'></td>";
								break;
						}
						?>	
						<?php
						switch ($monthlyReport->gubun_tp) {
							case 1 : // 이커머스
								echo "<td><input id='apd_dil_exp' name='apd_dil_exp' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->apd_dil_exp ) . "'></td>";
								break;
							case 2 : // 익스프레스
								echo "<td><input id='receipt_exp' name='receipt_exp' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->receipt_exp ) . "'></td>";
								break;
							case 3 : // 직영4대보험
								echo "<td><input id='meal_pay' name='meal_pay' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->meal_pay ) . "'></td>";
								break;
						}
						?>
						<?php
						switch ($monthlyReport->gubun_tp) {
							case 1 : // 이커머스
								echo "<td><input id='dil_etc_exp' name='dil_etc_exp' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->dil_etc_exp ) . "'></td>";
								break;
							case 2 : // 익스프레스
								echo "<td></td>";
								break;
							case 3 : // 직영4대보험
								echo "<td><input id='car_assist_amt' name='car_assist_amt' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->car_assist_amt ) . "'></td>";
								break;
						}
						?>
						<?php
						switch ($monthlyReport->gubun_tp) {
							case 1 : // 이커머스
								echo "<td><input id='receipt_exp' name='receipt_exp' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->receipt_exp ) . "'></td>";
								break;
							case 2 : // 익스프레스
								echo "<td></td>";
								break;
							case 3 : // 직영4대보험
								echo "<td><input id='etc_pay' name='etc_pay' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->etc_pay ) . "'></td>";
								break;
						}
						?>
						<?php
						switch ($monthlyReport->gubun_tp) {
							case 1 : // 이커머스
								echo "<td><input id='early_slot' name='early_slot' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->early_slot ) . "'></td>";
								break;
							case 2 : // 익스프레스
								echo "<td colspan='2'></td>";
								break;
							case 3 : // 직영4대보험
								echo "<td><input id='etc_amt' name='etc_amt' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->etc_amt ) . "'></td>";
								break;
						}
						?>
						<?php
						switch ($monthlyReport->gubun_tp) {
							case 1 : // 이커머스
								echo "<td><input id='per_incen_pay' name='per_incen_pay' type='text' class='form-control'";
								echo " maxlength='20'";
								echo " onkeyup='javascript:sumFareVal(this)'";
								echo " value='" . number_format ( $monthlyReport->per_incen_pay ) . "'></td>";
								break;
							case 2 : // 익스프레스
								break;
							case 3 : // 직영4대보험
								echo "<td></td>";
								break;
						}
						?>
					</tr>
					<tr>
						<td>운송료 합계:</td>
						<td colspan="10"><input id='fare_val' name='fare_val' type='text'
							class='form-control' maxlength='20' value='0' readonly="readonly"></td>
					</tr>
				</tbody>
				<!-- 			</table> -->
				<!-- 			<table class="table table-bordered"> -->
				<thead>
					<tr class="tr_head">
						<th colspan="11">공제</th>
					</tr>
					<tr>
						<?php
						switch ($monthlyReport->gubun_tp) {
							case 1 : // 이커머스
								echo "<th>관리비</th><th>부가세</th><th>보험료</th><th>회차</th><th style='width: 120px;'>환경개선/협회비</th><th>자동차세</th><th>GPS</th><th>과태료</th><th>사고접보비</th><th>유류연비차액</th><th></th>";
								break;
							case 2 : // 익스프레스
								echo "<th>관리비</th><th>부가세</th><th>보험료</th><th>회차</th><th>환경개선/협회비</th><th>자동차세</th><th>과태료</th><th>사고접보비</th><th>유류연비차액</th><th></th><th></th>";
								break;
							case 3 : // 직영4대보험
								echo "<th>국민연금</th><th>건강보험</th><th>장기요양</th><th>고용보험</th><th>갑근세</th><th>주민세</th><th>선급금</th><th>기타공제</th><th>지각/조퇴/결근공제</th><th></th>";
								break;
						}
						?>
					</tr>
				</thead>
				<tbody>
					<tr>
					<?php
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
						case 2 : // 익스프레스
							echo "<td><input id='mngt_exp' name='mngt_exp' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->mngt_exp ) . "'></td>";
							break;
						case 3 : // 직영4대보험
							echo "<td><input id='pension_fee' name='pension_fee' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->pension_fee ) . "'></td>";
							break;
					}
					?>
					<?php
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
						case 2 : // 익스프레스
							echo "<td><input id='surtax' name='surtax' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->surtax ) . "'></td>";
							break;
						case 3 : // 직영4대보험
							echo "<td><input id='insurance_fee' name='insurance_fee' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->insurance_fee ) . "'></td>";
							break;
					}
					?>
					<?php
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
						case 2 : // 익스프레스
							echo "<td><input id='insu_fee' name='insu_fee' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->insu_fee ) . "'></td>";
							break;
						case 3 : // 직영4대보험
							echo "<td><input id='recuperation_fee' name='recuperation_fee' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->recuperation_fee ) . "'></td>";
							break;
					}
					?>
					<?php
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
						case 2 : // 익스프레스
							echo "<td><input id='insu_deg' name='insu_deg' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->insu_deg ) . "'></td>";
							break;
						case 3 : // 직영4대보험
							echo "<td><input id='unemploy_insurance_fee' name='unemploy_insurance_fee' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->unemploy_insurance_fee ) . "'></td>";
							break;
					}
					?>
					<?php
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
						case 2 : // 익스프레스
							echo "<td><input id='commit_fee' name='commit_fee' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->commit_fee ) . "'></td>";
							break;
						case 3 : // 직영4대보험
							echo "<td><input id='income_tax' name='income_tax' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->income_tax ) . "'></td>";
							break;
					}
					?>
					<?php
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
						case 2 : // 익스프레스
							echo "<td><input id='car_tax' name='car_tax' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->car_tax ) . "'></td>";
							break;
						case 3 : // 직영4대보험
							echo "<td><input id='city_tax' name='city_tax' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->city_tax ) . "'></td>";
							break;
					}
					?>
					<?php
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
						case 2 : // 익스프레스
							echo "<td><input id='gps_fee' name='gps_fee' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->gps_fee ) . "'></td>";
							break;
						case 3 : // 직영4대보험
							echo "<td><input id='prepay_amt' name='prepay_amt' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->prepay_amt ) . "'></td>";
							break;
					}
					?>
					<?php
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
						case 2 : // 익스프레스
							echo "<td><input id='fine_fee' name='fine_fee' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->fine_fee ) . "'></td>";
							break;
						case 3 : // 직영4대보험
							echo "<td><input id='etc_deduct_amt' name='etc_deduct_amt' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->etc_deduct_amt ) . "'></td>";
							break;
					}
					?>
					<?php
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
						case 2 : // 익스프레스
							echo "<td><input id='acct_fee' name='acct_fee' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->acct_fee ) . "'></td>";
							break;
						case 3 : // 직영4대보험
							echo "<td><input id='attend_deduct_amt' name='attend_deduct_amt' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->attend_deduct_amt ) . "'></td>";
							break;
					}
					?>
					<?php
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
							echo "<td><input id='mileage_fee' name='mileage_fee' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->mileage_fee ) . "'></td>";
							echo "<td></td>";
							break;
						case 2 : // 익스프레스
							echo "<td></td>";
							echo "<td></td>";
							break;
						case 3 : // 직영4대보험
							echo "<td></td>";
							break;
					}
					?>
					</tr>
				</tbody>
				<thead>
					<tr>
					<?php
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
						case 2 : // 익스프레스
							echo "<th>출퇴근유류비</th><th>차량할부</th><th>할부회차</th><th>예치금</th><th>선지급</th><th>기장료</th><th>이체수수료</th><th>도색비</th><th>기타</th><th>사업소득세</th><th></th>";
							break;
						case 3 : // 직영4대보험
							echo "<th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th>";
							break;
					}
					?>
					</tr>
				</thead>
				<tbody>
					<tr>
					<?php
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
						case 2 : // 익스프레스
							echo "<td><input id='commute_oil_fee' name='commute_oil_fee' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->commute_oil_fee ) . "'></td>";
							break;
						case 3 : // 직영4대보험
							echo "<td></td>";
							break;
					}
					?>
					<?php
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
						case 2 : // 익스프레스
							echo "<td><input id='instl_fee' name='instl_fee' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->instl_fee ) . "'></td>";
							break;
						case 3 : // 직영4대보험
							echo "<td></td>";
							break;
					}
					?>
					<?php
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
						case 2 : // 익스프레스
							echo "<td><input id='instl_deg' name='instl_deg' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->instl_deg ) . "'></td>";
							break;
						case 3 : // 직영4대보험
							echo "<td></td>";
							break;
					}
					?>
					<?php
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
						case 2 : // 익스프레스
							echo "<td><input id='deposit' name='deposit' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->deposit ) . "'></td>";
							break;
						case 3 : // 직영4대보험
							echo "<td></td>";
							break;
					}
					?>
					<?php
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
						case 2 : // 익스프레스
							echo "<td><input id='ada_pay' name='ada_pay' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->ada_pay ) . "'></td>";
							break;
						case 3 : // 직영4대보험
							echo "<td></td>";
							break;
					}
					?>
					<?php
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
						case 2 : // 익스프레스
							echo "<td><input id='account_fee' name='account_fee' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->account_fee ) . "'></td>";
							break;
						case 3 : // 직영4대보험
							echo "<td></td>";
							break;
					}
					?>
					<?php
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
						case 2 : // 익스프레스
							echo "<td><input id='trans_fee' name='trans_fee' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->trans_fee ) . "'></td>";
							break;
						case 3 : // 직영4대보험
							echo "<td></td>";
							break;
					}
					?>
					<?php
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
						case 2 : // 익스프레스
							echo "<td><input id='paint_exp' name='paint_exp' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->paint_exp ) . "'></td>";
							break;
						case 3 : // 직영4대보험
							echo "<td></td>";
							break;
					}
					?>
					<?php
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
						case 2 : // 익스프레스
							echo "<td><input id='charoff_etc_fee' name='charoff_etc_fee' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->charoff_etc_fee ) . "'></td>";
							break;
						case 3 : // 직영4대보험
							echo "<td></td>";
							break;
					}
					?>
					<?php
					switch ($monthlyReport->gubun_tp) {
						case 1 : // 이커머스
						case 2 : // 익스프레스
							echo "<td><input id='incm_tax' name='incm_tax' type='text' class='form-control'";
							echo " maxlength='20'";
							echo " onkeyup='javascript:sumDedVal(this)'";
							echo " value='" . number_format ( $monthlyReport->incm_tax ) . "'></td>";
							echo "<td></td>";
							break;
						case 3 : // 직영4대보험
							echo "<td></td>";
							break;
					}
					?>
					</tr>
					<tr>
						<td>공제 합계:</td>
						<td colspan="10"><input id='ded_val' name='ded_val' type='text'
							class='form-control' maxlength='20' value='0' readonly="readonly">
						</td>
					</tr>
				</tbody>
				<thead>
					<tr class="tr_head">
						<th colspan="11">공지사항</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td colspan="11"><?php
						echo "<textarea id='notice' name='notice' type='text' class='form-control' rows='10' cols='50'>";
						echo $monthlyReport->month_notice;
						echo "</textarea>";
						?>
						</td>
					</tr>
				</tbody>
				<thead>
					<tr class="tr_head">
						<th colspan="11">비고</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td colspan="11"><?php
						echo "<textarea id='etc_text' name='etc_text' type='text' class='form-control' rows='10' cols='50'>";
						echo $monthlyReport->notice;
						echo "</textarea>";
						?>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		<div class="row row_margin">
			<div class="col-md-12 text-right">
				<button class="btn btn-lg btn-warning" type="submit" name="sb_bt"
					value="1">임시저장</button>
				<button class="btn btn-lg btn-success" type="submit" name="sb_bt"
					value="2">결산완료</button>
				<button class="btn btn-lg btn-danger" type="button"
					onclick="window.history.back();">취소</button>
			</div>
		</div>
		</form>
	</div>
	<!-- /container -->

	<!-- Bootstrap core JavaScript
    ================================================== -->
	<!-- Placed at the end of the document so the pages load faster -->
	<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
	<script src="./dist/js/bootstrap.min.js"></script>
	<script type="text/javascript">
	$(document).ready(function () {
		$('#fare_amt').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#comm_exp').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#car_wash_exp').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#attend_exp').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#incen_pay').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#dil_van_exp').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#apd_dil_exp').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#dil_etc_exp').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#receipt_exp').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});

		$('#mngt_exp').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#surtax').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#insu_fee').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#insu_deg').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#commit_fee').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#car_tax').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#gps_fee').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#fine_fee').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#acct_fee').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#mileage_fee').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});

		$('#commute_oil_fee').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#instl_fee').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#instl_deg').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#deposit').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#ada_pay').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#account_fee').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#trans_fee').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#paint_exp').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#charoff_etc_fee').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
		$('#incm_tax').tooltip({'trigger':'focus', 'title': '최대 20자 이내 숫자만 입력하세요.'});
	});

	$(window).load(function () {
		sumFareVal(document.getElementById('fare_amt'));
		sumDedVal(document.getElementById('mngt_exp'));
	});
	
	function checkNumber(obj, isWon)
	{
		if (obj.value.length > 0)
		{
			for (var i = 0; i < obj.value.length; i++)
			{
				if (!(isWon && obj.value.charAt(i) == ',') && (obj.value.charAt(i) < '0' || obj.value.charAt(i) > '9')) {
					obj.value = obj.value.substr(0,i);
				}
			}
			if (isWon) {
				obj.value = commaNum(obj.value);
			}
		}
	}

	function commaNum(num) {
		num = num.replace(/,/gi,'');
		var len, point, str;
		num = num + "";
		point = num.length % 3;
		len = num.length;

		str = num.substring(0, point);
		while (point < len) {
			if (str != "") str += ",";
			str += num.substring(point, point + 3);
			point += 3;
		}
		return str;
	}

	function sumFareVal(obj)
	{
		checkNumber(obj, true);
		var gubun = <?php echo $monthlyReport->gubun_tp ?>;
		var sum = 0;
		sum = Number(document.getElementById('fare_amt').value.replace(/,/gi,''));
		switch (gubun) {
		case 1 : // 이커머스
			sum += Number(document.getElementById('comm_exp').value.replace(/,/gi,''));
			sum += Number(document.getElementById('car_wash_exp').value.replace(/,/gi,''));
			sum += Number(document.getElementById('attend_exp').value.replace(/,/gi,''));
			sum += Number(document.getElementById('incen_pay').value.replace(/,/gi,''));
			sum -= Number(document.getElementById('dil_van_exp').value.replace(/,/gi,''));
			sum += Number(document.getElementById('apd_dil_exp').value.replace(/,/gi,''));
			sum += Number(document.getElementById('dil_etc_exp').value.replace(/,/gi,''));
			sum += Number(document.getElementById('receipt_exp').value.replace(/,/gi,''));
			sum += Number(document.getElementById('early_slot').value.replace(/,/gi,''));
			sum += Number(document.getElementById('per_incen_pay').value.replace(/,/gi,''));
			break;
		case 2 : // 익스프레스
			sum += Number(document.getElementById('oil_exp').value.replace(/,/gi,''));
			sum -= Number(document.getElementById('dayoff_dedt').value.replace(/,/gi,''));
			sum += Number(document.getElementById('ex_incen_pay').value.replace(/,/gi,''));
			sum += Number(document.getElementById('apd_dil_exp').value.replace(/,/gi,''));
			sum += Number(document.getElementById('dil_etc_exp').value.replace(/,/gi,''));
			sum -= Number(document.getElementById('receipt_exp').value.replace(/,/gi,''));
			break;
		case 3 : // 직영4대보험
			sum += Number(document.getElementById('extension_pay').value.replace(/,/gi,''));
			sum += Number(document.getElementById('annual_pay').value.replace(/,/gi,''));
			sum += Number(document.getElementById('early_slot').value.replace(/,/gi,''));
			sum += Number(document.getElementById('dispatcher_amt').value.replace(/,/gi,''));
			sum -= Number(document.getElementById('commit_pay').value.replace(/,/gi,''));
			sum += Number(document.getElementById('meal_pay').value.replace(/,/gi,''));
			sum += Number(document.getElementById('car_assist_amt').value.replace(/,/gi,''));
			sum += Number(document.getElementById('etc_pay').value.replace(/,/gi,''));
			sum += Number(document.getElementById('etc_amt').value.replace(/,/gi,''));
			break;
		}
		document.getElementById('fare_val').value = sum;
		checkNumber(document.getElementById('fare_val'), true);
		if(document.getElementById('soyu_tp').value == '직영' || document.getElementById('soyu_tp').value == '사업자'){
			document.getElementById('incm_tax').value = sum*0.033;
			checkNumber(document.getElementById('incm_tax'), true);
		}
		computeTotal();
	}

	function sumDedVal(obj)
	{
		checkNumber(obj, true);
		var gubun = <?php echo $monthlyReport->gubun_tp ?>;
		var sum = 0;
		switch (gubun) {
		case 1:
		case 2:
			sum = Number(document.getElementById('mngt_exp').value.replace(/,/gi,''));
			sum += Number(document.getElementById('surtax').value.replace(/,/gi,''));
			sum += Number(document.getElementById('insu_fee').value.replace(/,/gi,''));
			sum += Number(document.getElementById('insu_deg').value.replace(/,/gi,''));
			sum += Number(document.getElementById('commit_fee').value.replace(/,/gi,''));
			sum += Number(document.getElementById('car_tax').value.replace(/,/gi,''));
			sum += Number(document.getElementById('fine_fee').value.replace(/,/gi,''));
			sum += Number(document.getElementById('acct_fee').value.replace(/,/gi,''));
// 			sum += Number(document.getElementById('mileage_fee').value.replace(/,/gi,''));
			if (gubun == 1) {
				sum += Number(document.getElementById('gps_fee').value.replace(/,/gi,''));
			}
			sum += Number(document.getElementById('commute_oil_fee').value.replace(/,/gi,''));
			sum += Number(document.getElementById('instl_fee').value.replace(/,/gi,''));
			sum += Number(document.getElementById('instl_deg').value.replace(/,/gi,''));
			sum += Number(document.getElementById('deposit').value.replace(/,/gi,''));
			sum += Number(document.getElementById('ada_pay').value.replace(/,/gi,''));
			sum += Number(document.getElementById('account_fee').value.replace(/,/gi,''));
			sum += Number(document.getElementById('trans_fee').value.replace(/,/gi,''));
			sum += Number(document.getElementById('paint_exp').value.replace(/,/gi,''));
			sum += Number(document.getElementById('charoff_etc_fee').value.replace(/,/gi,''));
			sum += Number(document.getElementById('incm_tax').value.replace(/,/gi,''));
			break;
		case 3 :
			sum = Number(document.getElementById('pension_fee').value.replace(/,/gi,''));
			sum += Number(document.getElementById('insurance_fee').value.replace(/,/gi,''));
			sum += Number(document.getElementById('recuperation_fee').value.replace(/,/gi,''));
			sum += Number(document.getElementById('unemploy_insurance_fee').value.replace(/,/gi,''));
			sum += Number(document.getElementById('income_tax').value.replace(/,/gi,''));
			sum += Number(document.getElementById('city_tax').value.replace(/,/gi,''));
			sum += Number(document.getElementById('prepay_amt').value.replace(/,/gi,''));
			sum += Number(document.getElementById('etc_deduct_amt').value.replace(/,/gi,''));
			sum += Number(document.getElementById('attend_deduct_amt').value.replace(/,/gi,''));
			break;
		}

		document.getElementById('ded_val').value = sum;
		checkNumber(document.getElementById('ded_val'), true);
		computeTotal();
	}

	function computeTotal() {
		document.getElementById('total_sply_amt').value = Number(document.getElementById('fare_val').value.replace(/,/gi,'')) - Number(document.getElementById('ded_val').value.replace(/,/gi,''));
		checkNumber(document.getElementById('total_sply_amt'), true);
	} 
	</script>
</body>
</html>